<?php
session_start();
error_reporting(E_ERROR | E_WARNING | E_PARSE);
include 'includes/header.php';
my_header('Казина :: Jwakk');
?>
        <div class="line"></div>
        <div class="mainConteiner">
                
            <?php include 'includes'.DIRECTORY_SEPARATOR.'top.php'; ?>
            <div class="topDelimiter"></div>

            <div class="content">

                <table cellspacing="0" cellpadding="0" width="100%"><tr>

                        <td class="Mainmenu" valign="top">
                            <a href="index.php"><div class="manuB">Казина</div></a>
                            <a href="buyCasino.php"><div class="manuOnB">Купи казино</div></a>
                            <a href="yoursC.php"><div class="manuB">Твои казина</div></a>
                            <a href="fight.php"><div class="manuB">Сбий се</div></a>
                            <a href="work.php"><div class="manuB">Работа</div></a>
                            <a href="zalozi.php"><div class="manuB">Залози</div></a>
                            <a href="coffee.php"><div class="manuB">Градът</div></a>
                            <a href="profile.php?user=<?php echo $_SESSION['user_info']['user']; ?>"><div class="manuB">Профил</div></a>
                            <?php
								$mes_q = mysql_query('SELECT id FROM message WHERE `do`="'.$_SESSION['user_info']['user'].'" AND `read`="0"');
								$mes_n = mysql_num_rows($mes_q);
								echo '<a href="mail.php"><div class="manuB">Съобщения ['.$mes_n.']</div></a>';
							?>
                            <a href="index.php?logout"><div class="manuBLogOut">Изход</div></a>

                            <br/>
                            <a href="#"><img alt="Последвайте Jwakk в Facebook" src="img/facebook.png" /></a>
                            <a href="#"><img alt="Последвайте Jwakk в Twitter" src="img/twitter.png" /></a>
                            <a href="#"><img alt="Абонирайте се за RSS емисии" src="img/rss.png" /></a>
                        </td>

                        <td valign="top">
                            <div class="gameBorder">
                                <div class="TheGame">
                                    <div class="gameTitle">Създай своето казино</div>	

                                    <?php
                                        if($money>=10000 AND $level>=5){
                                                if($_POST['buy_sub']==1){
                                                    $name = $_POST['name'];
                                                    $me = $_SESSION['user_info']['user'];
                                                        if(strlen($name)<4){
                                                            $error_casino = 'Името не може да бъде по-малко от 4 символа.';
                                                        }
                                                        if(strlen($name)>30){
                                                            $error_casino = 'Името не може да бъде по-голямо от 30 символа.';
                                                        }   
                                                            
                                                            if(count($error_casino)==0){
                                                                mysql_query('INSERT INTO casino(name,`by`,date) VALUES("'.$name.'","'.$me.'",'.time().')');
                                                                mysql_query('UPDATE users SET money=money-10000 WHERE user="'.$me.'"');
                                                                $casino_name_q = mysql_query('SELECT casino_id FROM casino WHERE name="'.$name.'"');
                                                                $casino_name_f = mysql_fetch_assoc($casino_name_q);
                                                                if(mysql_error()){
                                                                    echo 'Грешка.';
                                                                }
                                                                else{
                                                                   echo '<meta http-equiv="refresh" content="0;url=casino.php?number='.$casino_name_f['casino_id'].'&admin">';
                                                                }
                                                            }
                                                }
                                            ?>
                                                <div class="access">Имаш всичко необходимо да създадеш казино.</div><br />
                                                    <?php
                                                        if(count($error_casino)>0){
                                                            echo '<div  class="overLevel">'.$error_casino.'</div><br />';
                                                        }
                                                    ?>
                                                <table width="100%"><tr>

                                            <td valign="top"> <form method="post" class="createCasino">
                                                    Име на казиното  <br/><input class="textF2" type="text" name="name" value="" /><br/><br/>
                                                    <span>Цена: 10,000$ </span> &nbsp;
                                                    <span>Ниво: 5 </span> &nbsp;
                                                    <br /><br />
                                                    <input type="hidden" name="buy_sub" value="1" />
                                                    <input class="but" type="submit" name="casinoName" value="Създай своето казино" />

                                                </form></td>

                                            <td align="right"><img class="casionPic" alt="create casino Jwakk" title="Създаи казино" src="img/casino.png"></td>

                                        </tr></table>
                                            <?php
                                        }
                                        else{
                                            ?>
                                                    <div class="overLevel">Нямаш нужните способност за да отвориш казино.</div><br />
                                                
                                                <table width="100%"><tr>

                                            <td valign="top"> <form method="post" class="createCasino">
                                                    Име на казиното  <br/><input class="textF2" type="text" name="casinoName" readonly="readonly" /><br/><br/>
                                                    <span>Цена: 10,000$ </span> &nbsp;
                                                    <span>Ниво: 5 </span> &nbsp;
                                                    <br /><br />

                                                </form></td>

                                            <td align="right"><img class="casionPic" alt="create casino Jwakk" title="Създаи казино" src="img/casino.png"></td>

                                        </tr></table>
                                            <?php
                                        }
                                        
                                    ?>
                                    
                                    
                                    <br/>

                                    

                                </div>
                            </div>
                            <div class="help"> <a href="#">Помощ</a> | <a href="#">FAQ</a> | <a href="#">Условия</a> | <a href="#">Facebook</a></div>
                        </td>

                    </tr></table>


                <div class="footer">
                    © JwakK.com · Всички права запазени · <a href="#">Условия за ползване</a>
                </div>
            </div>
        </div>

        <div class="bottom"></div>

    </body>
</html>